// 导入二次封装axios
import koi from "@/utils/axios.ts";

// 统一管理接口
enum API {
  LIST_PAGE = "/app/colecron/admin/cron/list",
  GET_BY_ID = "/app/colecron/admin/cron/read",
  UPDATE = "/app/colecron/admin/cron/update",
  ADD = "/app/colecron/admin/cron/add",
  UPDATE_STATE = "/app/colecron/admin/cron/changeStatus",
  CRON_LOG = "/app/colecron/admin/cron-log/list",
  RELOAD = "/app/colecron/admin/cron/reload",
}

export const listPage = (params: any) => {
  return koi.get(API.LIST_PAGE, params);
};

// 根据ID进行查询
export const read = (id: any) => {
  return koi.get(API.GET_BY_ID, { id });
};

// 根据ID进行修改
export const update = (data: any) => {
  return koi.post(API.UPDATE, data);
};

// 添加
export const add = (data: any) => {
  return koi.post(API.ADD, data);
};

export const changeStatus = (id: any, status: any) => {
  return koi.post(API.UPDATE_STATE, { id, status });
};

export const remove = (id: any) => {
  return koi.post(API.UPDATE_STATE, { id });
};
export const reload = (id: any) => {
  return koi.post(API.RELOAD, { id });
};

export const cronLog = (data: any) => {
  return koi.post(API.CRON_LOG, data);
};
